function interval(
  delay = 1000,
  callback: (id: number, resolve: (value: unknown) => void) => void
) {
  return new Promise((resolve) => {
    let id = setInterval(() => {
      callback(id, resolve);
    }, delay);
  });
}
let i = 1;
interval(100, (id,resolve) => {
  i++;
  console.log(i);
  if (i > 20) {
    resolve("定时器停止")
    clearInterval(id);
  }
}).then((res) => {
  return interval(100, (id, resolve) => {
    i++;
    console.log(i);
    if (i > 40) {
      resolve("定时器停止")
      clearInterval(id);
    }
  })
});
